﻿using DevExpress.XtraEditors;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lamex.mIE.Calculate
{
    public class LGC_VAL_BOM_P75
    {
        //"C、如果包含P75
        //a、子程序1、通过[BOM].[DRAWING_NO]条件，传参【P75_装铝材800】、【P75_装铝材801】、【800】，返回
        //b、子程序2、通过[BOM].[COMPONENT]条件，传参【P75_装码，P75_打螺丝，P75_套胶袋】，返回
        //c、子程序3、通过[BOM].[COMPONENT]条件，传参【P75_装屏风格_W800】、【P75_装屏风格_W801】、【800】，返回"
        public static DataTable LGC_VAL_BOM_P75_VALUE(DataTable dt_BOM, string DWG_No, string Part_No, string Process_Code, string WORKTIME_LOGIC_CODE)
        {
            string errorMsg = DWG_No + Part_No + Process_Code;
            try
            {
                //a.子程序1
                DataTable dt1 = Calculate.LGC_VAL_BOM_SUB1.LGC_VAL_BOM_SUB1_VALUE("P75_装铝材800", "P75_装铝材801", 800, dt_BOM, DWG_No, Part_No, Process_Code, WORKTIME_LOGIC_CODE);
                //b.子程序2
                DataTable dt2 = Calculate.LGC_VAL_BOM_SUB2.LGC_VAL_BOM_SUB2_VALUE(dt_BOM, DWG_No, Part_No, Process_Code, WORKTIME_LOGIC_CODE,
                    "P75_装码,P75_打螺丝");
                //c
                DataTable dt3 = Calculate.LGC_VAL_BOM_SUB3.LGC_VAL_BOM_SUB3_VALUE("P75_装屏风格_W800", "P75_装屏风格_W801", 800, dt_BOM, DWG_No, Part_No, Process_Code, WORKTIME_LOGIC_CODE);

                //d
                DataTable dt4 = Common.GetTable.GetTable_Feature();
                DataRow dr4 = dt4.NewRow();
                dr4["DWG_NO"] = DWG_No;
                dr4["PART_NO"] = Part_No;
                dr4["PROCESS_CODE"] = Process_Code;
                dr4["FEATURE_NAME"] = "P75_套胶袋";
                dr4["FEAT_VALUE"] = 1;
                dr4["LABOR_VALUE"] = Calculate.LGC_TIM_VTA.LGC_TIM_VTA_VALUE(DWG_No, Part_No, "P75_套胶袋", "", 1);//根据特征定义表工时字段计算
                dr4["UPDATE_TIME"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
                dr4["UPDATE_USER"] = Lamex.Common.Loginer.CurrentUser.AccountName;
                dt4.Rows.Add(dr4);
                
                //合并3个Datatable
                DataTable dtResult = new DataTable();
                dtResult.Merge(dt1);
                dtResult.Merge(dt2);
                dtResult.Merge(dt3);
                dtResult.Merge(dt4);

                return dtResult;
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(errorMsg + ex.Message);
                return null;
            }
        }
    }
}
